package com.zzyl.mapper;

import com.zzyl.dto.ResourceDto;
import com.zzyl.entity.Resource;
import com.zzyl.vo.MenuVo;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Service;

import java.util.List;

@Mapper
public interface ResourceMapper {


    List<Resource> selectResourceList(ResourceDto resourceDto);

    @Select("select * from sys_resource where resource_no=#{parentResourceNo}")
    Resource selectParentByNo(String parentResourceNo);

    void insert(Resource resource);

    int updateByPrimaryKeySelective(Resource resource);

    @Select("select * from sys_resource where resource_no=#{resourceNo}")
    Resource selectByResourceNo(String parentResourceNo);

    @Update("update sys_resource set data_state=#{dataState} where resource_no=#{resourceNo}")
    void updateByResourceNo(String resourceNo, String dataState);

    @Update("update sys_resource set data_state=#{dataState} where parent_resource_no=#{parentResourceNo}")
    void updateByParentResourceNo(String processString, String dataState);

    @Delete("delete from sys_resource where resource_no=#{resourceNo}")
    void deleteByResourceNo(String resourceNo);

    @Select("select count(1) from sys_resource where parent_resource_no=#{resourceNo}")
    int hasChildByMenuId(String resourceNo);

    List<Resource> selectListByUserId(Long userId);

    List<MenuVo> findListByUserId(Long userId);
}
